<template>
  <!-- 添加检查项 -->
  <div class="addCheck">
    <el-row>
      <el-col :span="24">
        <el-form :inline="true"
                 :model="proForm">
          <el-form-item label="工序状态">
            <el-input v-model="proForm.state"
                      disabled></el-input>
          </el-form-item>
          <el-form-item label="构件类型">
            <el-input v-model="proForm.type"
                      disabled></el-input>
          </el-form-item>
          <el-form-item label="检查项名称">
            <el-input v-model="proForm.project"
                      disabled></el-input>
          </el-form-item>
          <el-button type="primary"
                     @click="back">
            返回
          </el-button>
        </el-form>
      </el-col>
      <el-col :span="24"
              class="checkItem-col">
        <el-button class="float-right"
                   type="primary"
                   icon="el-icon-plus"
                   @click="addTable">新增</el-button>
        <el-form :inline="true"
                 :inline-message="true"
                 :rules="rules"
                 :model="ruleForm"
                 ref="ruleForm">
          <el-table :data="ruleForm.tableData"
                    class="checkItem-table"
                    height="310px"
                    :header-cell-style="{background:'#f5f5f5'}"
                    border
                    row-key="id">
            <el-table-column label="参数分类"
                             align="center"
                             show-overflow-tooltip>
              <template slot-scope="scope">
                <el-form-item :prop="'tableData.' + scope.$index+ '.param_type'"
                              :rules='rules.param_type'>
                  <el-select v-model="scope.row.param_type"
                             size="mini">
                    <el-option v-for="item in paramTypeData"
                               :key="item.content1"
                               :label="item.name"
                               :value="item.content1"></el-option>
                  </el-select>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="参数名"
                             align="center"
                             show-overflow-tooltip>
              <template slot-scope="scope">
                <el-form-item :prop="'tableData.' + scope.$index+ '.name'"
                              :rules='rules.name'>
                  <el-input v-model="scope.row.name"
                            size="mini"
                            @change="selectCode(scope.$index,scope.row.name,1)"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="参数代码"
                             align="center"
                             show-overflow-tooltip>
              <template slot-scope="scope">
                <el-form-item :prop="'tableData.' + scope.$index + '.key'"
                              :rules='rules.key'>
                  <el-input v-model="scope.row.key"
                            size="mini"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="数据类型"
                             align="center"
                             show-overflow-tooltip>
              <template slot-scope="scope">
                <el-form-item :prop="'tableData.' + scope.$index + '.data_type'"
                              :rules='rules.data_type'>
                  <el-select v-model="scope.row.data_type"
                             size="mini"
                             @change="selectDataType(scope.row.data_type,1)">
                    <el-option v-for="item in dataType"
                               :key="item.content1"
                               :label="item.name"
                               :value="item.content1"></el-option>
                  </el-select>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="最大长度"
                             align="center"
                             show-overflow-tooltip>
              <template slot-scope="scope">
                <el-form-item>
                  <el-input-number v-model="scope.row.length"
                                   :min="1"
                                   :controls="false"
                                   size="mini"></el-input-number>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="默认值"
                             align="center"
                             show-overflow-tooltip>
              <template slot-scope="scope">
                <el-form-item>
                  <el-input v-model="scope.row.default_value"
                            size="mini"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="字段控件"
                             align="center"
                             show-overflow-tooltip>
              <template slot-scope="scope">
                <el-form-item :prop="'tableData.' + scope.$index + '.control_type'"
                              :rules='rules.control_type'>
                  <el-select v-model="scope.row.control_type"
                             size="mini"
                             @change="controlSelect(scope.row.control_type,1)">
                    <el-option v-for="item in fieldControl"
                               :key="item.content1"
                               :label="item.name"
                               :value="item.content1"></el-option>
                  </el-select>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="控件配置"
                             align="center"
                             show-overflow-tooltip>
              <template slot-scope="scope">
                <el-form-item>
                  <el-button v-if="scope.row.control_type=='array' || scope.row.control_type=='object'"
                             type="primary"
                             icon="el-icon-plus"
                             size="mini"
                             @click="openControl(scope.$index,scope.row.control_type)">配置子控件</el-button>
                  <el-button v-if="scope.row.control_type=='listdrop' ||scope.row.control_type=='checkbox'||scope.row.control_type=='radio'"
                             type="primary"
                             icon="el-icon-plus"
                             size="mini"
                             @click="openConfig(scope.$index)">选项配置</el-button>
                  <el-input v-if="scope.row.control_type=='dictionary' "
                            v-model="scope.row.dictionary"
                            size="mini"
                            placeholder="请输入数据字典"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="字段校验"
                             align="center"
                             show-overflow-tooltip>
              <template slot-scope="scope">
                <el-form-item :prop="'tableData.' + scope.$index + '.check_type'"
                              :rules='rules.check_type'>
                  <el-select v-model="scope.row.check_type"
                             multiple
                             placeholder="请选择"
                             collapse-tags
                             size="mini">
                    <el-option v-for="item in fieldCheck"
                               :key="item.content1"
                               :label="item.name"
                               :value="item.content1">
                    </el-option>
                  </el-select>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="排序"
                             align="center"
                             show-overflow-tooltip>
              <template slot-scope="scope">
                <el-form-item :prop="'tableData.' + scope.$index + '.sort'"
                              :rules='rules.sort'>
                  <el-input v-model="scope.row.sort"
                            size="mini"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="操作"
                             align="center">
              <template slot-scope="scope">
                <el-tooltip content="删除"
                            placement="top">
                  <el-button size="mini"
                             type="info"
                             icon="el-icon-error"
                             @click="deleteRow(scope.$index,ruleForm.tableData,scope.row.id)"></el-button>
                </el-tooltip>
              </template>
            </el-table-column>
          </el-table>
        </el-form>
      </el-col>
      <el-col :span="24"
              class="dialog-col">
        <el-button @click="cancel">取 消</el-button>
        <el-button type="success"
                   @click="submitForm('ruleForm')">保 存</el-button>
      </el-col>
    </el-row>
    <el-dialog title="配置子控件"
               :visible.sync="add"
               :modal="false"
               width="80%">
      <el-button class="float-right"
                 type="primary"
                 icon="el-icon-plus"
                 @click="addControl">新增</el-button>
      <el-form :rules="rules"
               :model="ruleForm1"
               ref="ruleForm1">
        <el-table :data="ruleForm1.controlData"
                  style="width: 100%">
          <el-table-column label="参数名"
                           align="center">
            <template slot-scope="scope">
              <el-form-item :prop="'controlData.' + scope.$index+ '.name'"
                            :rules='rules.name'>
                <el-input v-model="scope.row.name"
                          size="mini"
                          @change="selectCode(scope.$index,scope.row.name,2)"></el-input>
              </el-form-item>
            </template>
          </el-table-column>
          <el-table-column label="参数代码"
                           align="center">
            <template slot-scope="scope">
              <el-form-item :prop="'controlData.' + scope.$index + '.key'"
                            :rules='rules.key'>
                <el-input v-model="scope.row.key"
                          size="mini"></el-input>
              </el-form-item>
            </template>
          </el-table-column>
          <el-table-column label="数据类型"
                           align="center">
            <template slot-scope="scope">
              <el-form-item :prop="'controlData.' + scope.$index + '.data_type'"
                            :rules='rules.data_type'>
                <el-select v-model="scope.row.data_type"
                           size="mini"
                           @change="selectDataType(scope.row.data_type,2)">
                  <el-option v-for="item in dataType"
                             :key="item.content1"
                             :label="item.name"
                             :value="item.content1"></el-option>
                </el-select>
              </el-form-item>
            </template>
          </el-table-column>
          <el-table-column label="最大长度"
                           align="center">
            <template slot-scope="scope">
              <el-form-item style="width:100%!important;">
                <el-input-number v-model="scope.row.length"
                                 :min="1"
                                 :controls="false"
                                 size="mini"></el-input-number>
              </el-form-item>
            </template>
          </el-table-column>
          <el-table-column label="默认值"
                           align="center">
            <template slot-scope="scope">
              <el-form-item>
                <el-input v-model="scope.row.default_value"
                          size="mini"></el-input>
              </el-form-item>
            </template>
          </el-table-column>
          <el-table-column label="字段控件"
                           align="center">
            <template slot-scope="scope">
              <el-form-item :prop="'controlData.' + scope.$index + '.control_type'"
                            :rules='rules.control_type'>
                <el-select v-model="scope.row.control_type"
                           size="mini"
                           @change="controlSelect(scope.row.control_type,2)">
                  <el-option v-for="item in fieldControl2"
                             :key="item.content1"
                             :label="item.name"
                             :value="item.content1"></el-option>
                </el-select>
              </el-form-item>
            </template>
          </el-table-column>
          <el-table-column label="控件配置"
                           align="center">
            <template slot-scope="scope">
              <el-form-item>
                <el-button v-if="scope.row.control_type=='array' || scope.row.control_type=='object'"
                           type="primary"
                           icon="el-icon-plus"
                           size="mini"
                           @click="openChildControl(scope.$index,scope.row.control_type)">配置子控件</el-button>
                <el-button v-if="scope.row.control_type=='listdrop' ||scope.row.control_type=='checkbox'||scope.row.control_type=='radio'"
                           type="primary"
                           icon="el-icon-plus"
                           size="mini"
                           @click="openChildConfig(scope.$index)">选项配置</el-button>
                <el-input v-if="scope.row.control_type=='dictionary' "
                          v-model="scope.row.dictionary"
                          size="mini"
                          placeholder="请输入数据字典"></el-input>
              </el-form-item>
            </template>
          </el-table-column>
          <el-table-column label="字段校验"
                           align="center">
            <template slot-scope="scope">
              <el-form-item :prop="'controlData.' + scope.$index + '.check_type'"
                            :rules='rules.check_type'>
                <el-select v-model="scope.row.check_type"
                           multiple
                           placeholder="请选择"
                           collapse-tags
                           size="mini">
                  <el-option v-for="item in fieldCheck2"
                             :key="item.content1"
                             :label="item.name"
                             :value="item.content1">
                  </el-option>
                </el-select>
              </el-form-item>
            </template>
          </el-table-column>
          <el-table-column label="排序"
                           align="center">
            <template slot-scope="scope">
              <el-form-item :prop="'controlData.' + scope.$index + '.sort'"
                            :rules='rules.sort'>
                <el-input v-model="scope.row.sort"
                          size="mini"></el-input>
              </el-form-item>
            </template>
          </el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-tooltip content="删除"
                          placement="top">
                <el-button size="mini"
                           type="info"
                           icon="el-icon-error"
                           @click="deleteRow(scope.$index,ruleForm1.controlData,scope.row.id)"></el-button>
              </el-tooltip>
            </template>
          </el-table-column>
        </el-table>
      </el-form>
      <div class="btn-col">
        <el-button @click="add=false">取 消</el-button>
        <el-button type="success"
                   @click="submitForm1('ruleForm1')">保 存</el-button>
      </div>
      <el-dialog title="配置子控件"
                 :visible.sync="addChild"
                 :modal="false"
                 width="75%"
                 append-to-body>
        <el-button class="float-right"
                   type="primary"
                   icon="el-icon-plus"
                   @click="addChildControl">新增</el-button>
        <el-form :rules="rules"
                 :model="ruleForm2"
                 ref="ruleForm2">
          <el-table :data="ruleForm2.controlChildData"
                    style="width: 100%">
            <el-table-column label="参数名"
                             align="center">
              <template slot-scope="scope">
                <el-form-item :prop="'controlChildData.' + scope.$index+ '.name'"
                              :rules='rules.name'>
                  <el-input v-model="scope.row.name"
                            size="mini"
                            @change="selectCode(scope.$index,scope.row.name,3)"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="参数代码"
                             align="center">
              <template slot-scope="scope">
                <el-form-item :prop="'controlChildData.' + scope.$index + '.key'"
                              :rules='rules.key'>
                  <el-input v-model="scope.row.key"
                            size="mini"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="数据类型"
                             align="center">
              <template slot-scope="scope">
                <el-form-item :prop="'controlChildData.' + scope.$index + '.data_type'"
                              :rules='rules.data_type'>
                  <el-select v-model="scope.row.data_type"
                             size="mini"
                             @change="selectDataType(scope.row.data_type,3)">
                    <el-option v-for="item in dataType"
                               :key="item.content1"
                               :label="item.name"
                               :value="item.content1"></el-option>
                  </el-select>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="最大长度"
                             align="center">
              <template slot-scope="scope">
                <el-form-item>
                  <el-input-number v-model="scope.row.length"
                                   :min="1"
                                   :controls="false"
                                   size="mini"></el-input-number>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="默认值"
                             align="center">
              <template slot-scope="scope">
                <el-form-item>
                  <el-input v-model="scope.row.default_value"
                            size="mini"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="字段控件"
                             align="center">
              <template slot-scope="scope">
                <el-form-item :prop="'controlChildData.' + scope.$index + '.control_type'"
                              :rules='rules.control_type'>
                  <el-select v-model="scope.row.control_type"
                             size="mini"
                             @change="controlSelect(scope.row.control_type,3)">
                    <el-option v-for="item in fieldControl3"
                               :key="item.content1"
                               :label="item.name"
                               :value="item.content1"></el-option>
                  </el-select>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="字段校验"
                             align="center">
              <template slot-scope="scope">
                <el-form-item :prop="'controlChildData.' + scope.$index + '.check_type'"
                              :rules='rules.check_type'>
                  <el-select v-model="scope.row.check_type"
                             multiple
                             placeholder="请选择"
                             collapse-tags
                             size="mini">
                    <el-option v-for="item in fieldCheck3"
                               :key="item.content1"
                               :label="item.name"
                               :value="item.content1">
                    </el-option>
                  </el-select>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="排序"
                             align="center">
              <template slot-scope="scope">
                <el-form-item :prop="'controlChildData.' + scope.$index + '.sort'"
                              :rules='rules.sort'>
                  <el-input v-model="scope.row.sort"
                            size="mini"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="操作">
              <template slot-scope="scope">
                <el-tooltip content="删除"
                            placement="top">
                  <el-button size="mini"
                             type="info"
                             icon="el-icon-error"
                             @click="deleteRow(scope.$index,ruleForm2.controlChildData,scope.row.id)"></el-button>
                </el-tooltip>
              </template>
            </el-table-column>
          </el-table>
        </el-form>
        <div class="btn-col">
          <el-button @click="addChild=false">取 消</el-button>
          <el-button type="success"
                     @click="submitForm2('ruleForm2')">保 存</el-button>
        </div>
      </el-dialog>
    </el-dialog>
    <el-dialog title="选项配置"
               :visible.sync="optionConfig"
               :modal="false"
               width="35%">
      <el-table :data="optionData"
                style="width: 100%">
        <el-table-column label="描述"
                         align="center">
          <template slot-scope="scope">
            <el-input v-model="scope.row.name"
                      size="mini"></el-input>
          </template>
        </el-table-column>
        <el-table-column label="值"
                         align="center">
          <template slot-scope="scope">
            <el-input v-model="scope.row.key"
                      size="mini"></el-input>
          </template>
        </el-table-column>
        <el-table-column :render-header="renderHeader"
                         align="center">
          <template slot-scope="scope">
            <el-tooltip content="删除"
                        placement="top">
              <el-button size="mini"
                         type="info"
                         icon="el-icon-error"
                         @click="deleteRow(scope.$index,optionData,scope.row.id)"></el-button>
            </el-tooltip>
          </template>
        </el-table-column>
      </el-table>
      <div class="btn-col">
        <el-button @click="optionConfig=false">取 消</el-button>
        <el-button type="success"
                   @click="submitForm3">保 存</el-button>
      </div>
    </el-dialog>
    <el-dialog title="选项配置"
               :visible.sync="optionConfig1"
               :modal="false"
               width="35%">
      <el-table :data="optionChildData"
                style="width: 100%">
        <el-table-column label="描述"
                         align="center">
          <template slot-scope="scope">
            <el-input v-model="scope.row.name"
                      size="mini"></el-input>
          </template>
        </el-table-column>
        <el-table-column label="值"
                         align="center">
          <template slot-scope="scope">
            <el-input v-model="scope.row.key"
                      size="mini"></el-input>
          </template>
        </el-table-column>
        <el-table-column :render-header="renderHeader1"
                         align="center">
          <template slot-scope="scope">
            <el-tooltip content="删除"
                        placement="top">
              <el-button size="mini"
                         type="info"
                         icon="el-icon-error"
                         @click="deleteRow(scope.$index,optionChildData,scope.row.id)"></el-button>
            </el-tooltip>
          </template>
        </el-table-column>
      </el-table>
      <div class="btn-col">
        <el-button @click="optionConfig1=false">取 消</el-button>
        <el-button type="success"
                   @click="submitForm4">保 存</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
// 拼音
// import 'pinyin4js';

import { checkItemConfigApi } from '@/services/SystemSetting'
export default {
  data () {
    return {
      proForm: {
        state: '',
        type: '',
        project: '',
        proccess_id: '',
        component_type_id: '',
        major_id: ''
      },
      ruleForm: {
        tableData: []
      },
      ruleForm1: {
        controlData: []
      },
      ruleForm2: {
        controlChildData: []
      },
      optionData: [{
      }],
      optionChildData: [{
      }],
      add: false,
      optionConfig: false,
      optionConfig1: false,
      addChild: false,
      paramTypeData: [],
      dataType: [],
      fieldControl: [],
      fieldCheck: [],
      fieldControl2: [],
      fieldCheck2: [],
      fieldControl3: [],
      fieldCheck3: [],
      select: false,
      select1: false,
      control: '',
      control2: '',
      config: '',
      config2: '',
      rules: {
        param_type: [
          { required: true, message: '请选择参数分类', trigger: 'change' }
        ],
        name: [
          { required: true, message: '请输入参数名', trigger: 'blur' }
        ],
        key: [
          { required: true, message: '请输入参数代码', trigger: 'blur' }
        ],
        data_type: [
          { required: true, message: '请选择数据类型', trigger: 'change' }
        ],
        control_type: [
          { required: true, message: '请选择字段控件', trigger: 'change' }
        ],
        check_type: [
          { required: true, message: '请选择字段校验', trigger: 'blur' }
        ],
        sort: [
          { required: true, message: '请输入排序', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    renderHeader (h) {
      return (
        <div>
          <el-button type='primary' size='mini' onClick={this.addOptions} icon="el-icon-plus"></el-button>
        </div>
      )
    },
    renderHeader1 (h) {
      return (
        <div>
          <el-button type='primary' size='mini' onClick={this.addChildOptions} icon="el-icon-plus"></el-button>
        </div>
      )
    },
    // 列表
    getData () {
      // axios.get('admin/item/getdetail', { params: { check_id: this.$route.query.id, uuid: sessionStorage.getItem("uuid") } }, {
      //   headers: {
      //     'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
      //   }
      // }).then(res => {
      //   this.ruleForm.tableData = res.data.data.items;
      //   this.proForm.state = res.data.data.proccess_name;
      //   this.proForm.type = res.data.data.type_name;
      //   this.proForm.project = res.data.data.check_name;
      //   this.proForm.proccess_id = res.data.data.proccess_id;
      //   this.proForm.component_type_id = res.data.data.component_type_id;
      //   this.proForm.major_id = res.data.data.major_id;
      //   for (var i = 0; i < this.ruleForm.tableData.length; i++) {
      //     if (this.ruleForm.tableData[i].data_type != '') {
      //       this.selectDataType(this.ruleForm.tableData[i].data_type, 1);
      //       this.controlSelect(this.ruleForm.tableData[i].control_type, 1);
      //     }
      //   }
      // }, err => {
      //   console.log(err)
      // })
    },
    // 新增检查项
    addTable () {
      var table = {
        param_type: '',
        name: '',
        key: '',
        data_type: '',
        length: '',
        default_value: '',
        control_type: '',
        check_type: [],
        sort: '',
        children: [],
        id: ''
      }
      this.ruleForm.tableData.push(table)
    },
    // 新增子控件行
    addControl () {
      // var table = {
      //   name: '',
      //   key: '',
      //   data_type: '',
      //   length: '',
      //   default_value: '',
      //   control_type: '',
      //   check_type: [],
      //   sort: '',
      //   children: [],
      //   id: '',
      //   value: '',
      // }
      // this.ruleForm1.controlData.push(table)
    },
    // 新增二级子控件行
    addChildControl () {
      // var table = {
      //   name: '',
      //   key: '',
      //   data_type: '',
      //   length: '',
      //   default_value: '',
      //   control_type: '',
      //   check_type: [],
      //   sort: '',
      //   id: '',
      //   value: '',
      // }
      // this.ruleForm2.controlChildData.push(table)
    },
    // 新增选项配置
    addOptions () {
      var options = {
        name: '',
        key: '',
        id: ''
      }
      this.optionData.push(options)
    },
    addChildOptions () {
      var options = {
        name: '',
        key: '',
        id: ''
      }
      this.optionChildData.push(options)
    },
    // 参数代码
    selectCode (i, data, num) {
      if (num == 1) {
        this.ruleForm.tableData[i].key = PinyinHelper.getShortPinyin(data)
      } else if (num == 2) {
        this.ruleForm1.controlData[i].key = PinyinHelper.getShortPinyin(data)
      } else {
        this.ruleForm2.controlChildData[i].key = PinyinHelper.getShortPinyin(data)
      }
    },

    deleteRow (index, arr, id) {
      this.$confirm('此操作将永久删除, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {

      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除!'
        })
      })

      // if (id != "") {
      //   axios.post('admin/item/del', qs.stringify({ item_id: id, uuid: sessionStorage.getItem("uuid") }), {
      //     headers: {
      //       'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
      //     }
      //   }).then(res => {
      //     if (res.data.code == 1) {
      //       this.$message({
      //         message: '删除成功',
      //         type: 'success'
      //       });
      //       arr.splice(index, 1)
      //     } else {
      //       this.$message.error(res.data.msg)
      //     }
      //   }, err => {
      //     console.log(err)
      //   })
      // } else {
      //   arr.splice(index, 1)
      // }
    },
    submitForm (formName) {
      // this.$nextTick(() => {
      //   this.$refs[formName].validate((valid) => {
      //     if (valid) {
      //       axios.post('admin/item/change', qs.stringify({ check_id: this.$route.query.id, proccess_id: this.proForm.proccess_id, component_type_id: this.proForm.component_type_id, major_id: this.proForm.major_id, uuid: sessionStorage.getItem("uuid"), data: JSON.stringify(this.ruleForm.tableData) }), {
      //         headers: {
      //           'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
      //         }
      //       }).then(res => {
      //         if (res.data.code == 1) {
      //           this.$message({
      //             message: '添加成功',
      //             type: 'success'
      //           });
      //           this.getData();
      //           this.add = false;
      //           this.$refs[formName].resetFields();
      //         } else {
      //           this.$message.error(res.data.msg)
      //           this.$refs[formName].resetFields();
      //         }
      //       }, err => {
      //         console.log(err)
      //       })
      //     } else {
      //       console.log('error submit!!');
      //       return false;
      //     }
      //   });
      // })
    },
    submitForm1 (formName) {
      // this.$refs[formName].validate((valid) => {
      //   if (valid) {
      //     this.ruleForm.tableData[this.control].children = this.ruleForm1.controlData;
      //     this.add = false;
      //   } else {
      //     return false;
      //   }
      // });
    },
    submitForm2 (formName) {
      // this.$refs[formName].validate((valid) => {
      //   if (valid) {
      //     this.ruleForm1.controlData[this.control2].children = this.ruleForm2.controlChildData;
      //     this.addChild = false;
      //   } else {
      //     return false;
      //   }
      // });
    },
    submitForm3 () {
      // this.ruleForm.tableData[this.config].children = this.optionData;
      // this.optionConfig = false
    },
    submitForm4 () {
      // this.ruleForm1.controlData[config2].children = this.optionChildData;
      // this.optionConfig1 = false;
    },
    cancel () {
      // this.$router.go(-1)
      this.$router.push({ path: '/configure' })
    },
    // 参数分类下拉框
    getParamType () {
      // axios.get('admin/base/codes/data', { params: { codeType: 'param_type', uuid: sessionStorage.getItem("uuid") } }, {
      //   headers: {
      //     'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
      //   }
      // }).then(res => {
      //   this.paramTypeData = res.data.data.data
      // }, err => {
      //   console.log(err)
      // })
    },
    // 数据类型下拉框
    getDataType () {
      // axios.get('admin/base/codes/data', { params: { codeType: 'data_type', uuid: sessionStorage.getItem("uuid") } }, {
      //   headers: {
      //     'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
      //   }
      // }).then(res => {
      //   this.dataType = res.data.data.data
      // }, err => {
      //   console.log(err)
      // })
    },
    // 字段控件下拉框
    getfieldControl (data, num) {
      // axios.get('admin/base/codes/data', { params: { codeType: 'field_control', values: data, uuid: sessionStorage.getItem("uuid") } }, {
      //   headers: {
      //     'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
      //   }
      // }).then(res => {
      //   if (num == 1) { this.fieldControl = res.data.data.data };
      //   if (num == 2) { this.fieldControl2 = res.data.data.data };
      //   if (num == 3) { this.fieldControl3 = res.data.data.data }
      // }, err => {
      //   console.log(err)
      // })
    },
    // 数据校验下拉框
    getFieldCheck (data, num) {
      // axios.get('admin/base/codes/data', { params: { codeType: 'field_check', values: data, uuid: sessionStorage.getItem("uuid") } }, {
      //   headers: {
      //     'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
      //   }
      // }).then(res => {
      //   if (num == 1) { this.fieldCheck = res.data.data.data };
      //   if (num == 2) { this.fieldCheck2 = res.data.data.data };
      //   if (num == 3) { this.fieldCheck3 = res.data.data.data }
      // }, err => {
      //   console.log(err)
      // })
    },
    selectDataType (value, num) {
      // var data;
      // for (var i = 0; i < this.dataType.length; i++) {
      //   if (value == this.dataType[i].content1) {
      //     data = this.dataType[i].content2
      //   }
      // }
      // this.getfieldControl(data, num);
    },
    controlSelect (value, num) {
      // var data;
      // for (var i = 0; i < this.fieldControl.length; i++) {
      //   if (value == this.fieldControl[i].content1) {
      //     data = this.fieldControl[i].content2
      //   }
      // }
      // this.getFieldCheck(data, num);
    },
    openControl (index, data) {
      // this.add = true;
      // this.ruleForm1.controlData = this.ruleForm.tableData[index].children;
      // for (var i = 0; i < this.ruleForm1.controlData.length; i++) {
      //   if (this.ruleForm1.controlData[i].data_type != '') {
      //     this.selectDataType(this.ruleForm1.controlData[i].data_type, 2);
      //     this.controlSelect(this.ruleForm1.controlData[i].control_type, 2);
      //   }
      // };
      // this.control = index;
    },
    openChildControl (index, data) {
      // this.addChild = true;
      // this.ruleForm2.controlChildData = this.ruleForm1.controlData[index].children;
      // for (var i = 0; i < this.ruleForm2.controlChildData.length; i++) {
      //   if (this.ruleForm2.controlChildData.data_type != '') {
      //     this.selectDataType(this.ruleForm2.controlChildData.data_type, 3);
      //     this.controlSelect(this.ruleForm2.controlChildData.control_type, 3);
      //   }
      // };
      // this.control2 = index;
    },
    openConfig (index) {
      // this.optionConfig = true;
      // this.optionData = this.ruleForm.tableData[index].children;
      // this.config = index
    },
    openChildConfig (index) {
      // this.optionConfig1 = true;
      // this.select1 = data;
      // this.optionChildData = this.ruleForm1.controlData[index].children;
      // this.config2 = index
    }
  },
  mounted () {
    // this.getData();
    // this.getParamType();
    // this.getDataType();

  }
}
</script>
<style lang="scss" scoped>
.addCheck {
  padding: 15px;
  .checkItem-col {
    text-align: right;
    .checkItem-table {
      width: 100%;
      margin-top: 20px !important;
    }
  }
  .dialog-col {
    text-align: center;
    margin-top: 20px;
  }
  .btn-col {
    text-align: center;
    margin-top: 20px;
  }
}
</style>
